//
//  SchedulingViewController.m
//  pb
//
//  Created by 马田成 on 2017/5/5.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "SchedulingViewController.h"
#import "loginViewController.h"
#import "todayView.h"
#import "monthView.h"

@interface SchedulingViewController (){

    UISegmentedControl *segment;
    todayView *today;
    monthView *month;
}

@end

@implementation SchedulingViewController

- (void)viewWillAppear:(BOOL)animated{
    
//    [today removeFromSuperview];
//
//    today = [[todayView alloc]init];
//    today.hidden = NO;
//    today.vc = self;
//    today.frame = CGRectMake(0, 0, scrWidth(), scrHeight() - 64 - 44);
//    [self.view addSubview:today];
//    segment.selectedSegmentIndex = 0;
    
    [today loginIs];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
    [self leftNavHide];
    self.view.backgroundColor = getColor(@"ffffff");
}

#pragma mark --------------------- init --------------------

- (void)initView{

    //先生成存放标题的数据
    NSArray *array = [NSArray arrayWithObjects:@"今日行程",@"月度计划", nil];
    //初始化UISegmentedControl
    segment = [[UISegmentedControl alloc]initWithItems:array];
    //设置frame
    segment.frame = CGRectMake(screenScale(196), screenScale(50), scrWidth() - screenScale(196)*2, screenScale(50));
    //
    segment.selectedSegmentIndex = 0;
    //添加到视图
    self.navigationItem.titleView = segment;
    //添加事件
    [segment addTarget:self action:@selector(segmentClick:) forControlEvents:UIControlEventValueChanged];
    
    today = [[todayView alloc]init];
    today.hidden = NO;
    today.vc = self;
    today.frame = CGRectMake(0, 0, scrWidth(), scrHeight() - 64 - 44);
    [self.view addSubview:today];
    
    month = [[monthView alloc]init];
    month.hidden = YES;
    month.vc = self;
    month.frame = CGRectMake(0, 0, scrWidth(), scrHeight() - 64 - 44);
    [self.view addSubview:month];
}

#pragma mark --------------------- click --------------------

-(void)segmentClick:(UISegmentedControl *)sender{
    
    if (sender.selectedSegmentIndex == 0) {
        
        today.hidden = NO;
        month.hidden = YES;
        
    }else if (sender.selectedSegmentIndex == 1){
        
        today.hidden = YES;
        month.hidden = NO;
    }
}

@end
